<template>
	<view>
		<view class="BIG-cell-box">
			<view class="BIG-PL-head">
				<text>商品评论</text> <text class="plNum">({{commentNum}})</text>
				<!-- <view @click="toPlpage" class="BIG-PL-more">
					查看全部<uni-icons class="icon-BIG" type="right" size="12" color="#999999"></uni-icons>
		
				</view> -->
			</view>
			<view class="BIG-cell-PL-content" v-for="(item,index) in commentList" :key="index">
				<view class="BIG-cell-PL-top">
					<view class="imgBOX">
						<image :src="item.user.avatar" mode=""></image>
					</view>
					<view class="BIG-cell-PL-main">
						<text class="title">{{item.user.nickname}}</text>
						<text class="time">{{item.updatetime}}</text>
					</view>
					<uni-rate :readonly="true" :value="item.level" />
				</view>
				<view class="BIG-cell-PL-text">
					{{item.content}}
					<view class="BIGPJ_imgBox" v-if="item.images.length!==0">
						<image  @click="onGoodsSwiperPJ(item.images,inde)" v-for="(itq,inde) in item.images" :src="itq" mode="aspectFill"></image>
						<!-- <video :id="item.id" @play="playFullscreen(item.id)" v-if="item.video!==''" :src="$IMG_URL+item.video"></video> -->
						<image v-if="item.video!==''" @click="playVideo($IMG_URL+ item.video)" src="../../static/htz-image-upload/play.png" mode=""></image>
					</view>
				</view>
			</view>
			
				
		</view>
		<view class="video-container" v-show="showVideo">
			<uni-icons color="#fff" class="close-button"  type="closeempty" size="30" @click="closeVideo"></uni-icons>
		     <video v-if="showVideo" :autoplay="true" :src="videoSrc" class="video" :style="videoStyle"></video>
		    </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				videoSrc: '视频地址',
				showVideo: false,
				videoStyle: '',
				commentList:[],
				commentNum:'',
				page:1,
				lastPage:null,
				goodsID:''
			};
		},
		onLoad(options) {
			console.log(options);
			// this.getCommentList(options.id)
			this.goodsID = options.id
			this.getCommentList()
		},
		onReachBottom() {
			this.getCommentList()
		},
		methods:{
			closeVideo(){
				this.showVideo = false;
				this.videoStyle = '';
				      const videoContext = uni.createVideoContext('video');
				      videoContext.pause();
				      videoContext.exitFullScreen();
			},
			playVideo(url){
				console.log('视频地址',url);
				this.showVideo = true;
				this.videoSrc = url
				this.videoStyle = 'width: 90vw; height: 100vh; object-fit: fill;';
				const videoContext = uni.createVideoContext('video');
				videoContext.play();
				videoContext.requestFullScreen();
				// uni.createVideoContext(id.toString(), this).requestFullScreen(); 
			},
			playFullscreen(id) {
				console.log(id);
				uni.createVideoContext(id.toString(), this).requestFullScreen();
			      // const video = uni.createVideoContext('video',this);
			      // video.requestFullScreen();
			    },
			getCommentList() {
				if(this.page>this.lastPage&&this.lastPage!==null){
					return uni.showToast({
						title:'已全部加载完毕',
						icon:'none'
					})
					
				}
				this.$http('goods.commentList', {
					goods_id: this.goodsID,
					per_page: 10,
					type: 'all',
					page:this.page
				}).then(res => {
					if (res.code === 1) {
						console.log(res);
						if(this.page==1){
							this.commentList = res.data.data;
						} else {
							this.commentList = this.commentList.push(...res.data.data)
						}
						
						this.commentNum = res.data.total;
						this.lastPage = res.data.last_page
						this.page += 1
					}
					// if(this.lastPage!==this.page){
						
					// }
				});
			},
			// 评价图片预览
			onGoodsSwiperPJ(list,e) {
				console.log(e);
				this.$tools.previewImage(list, e);
			},
		}
	}
</script>

<style lang="scss">
	.video-container {
	  position: fixed;
	  top: 0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	  z-index: 9999;
	  background-color: black;
	  display: flex;
	  flex-direction: column;
	  justify-content: flex-start;
	  align-items: flex-end;
	  padding: 20px;
	  box-sizing: border-box;
	}
	.close-button {
		position: absolute;
		left: 2vh;
		top: 4vh;
	  cursor: pointer;
	}
	
	.video {
	  width: 100%;
	  height: 85vh;
	  margin-top: 15%;
	  margin-left: 2%;
	  // position: absolute;
	  // bottom: 0;
	  // left: 50%;
	  // transform: translateX(-50%);
	}
	.BIGPJ_imgBox {
		margin-top: 15px;
		image {
			max-width: 30%;
			max-height: 100px;
			margin-right: 5%;
			&:nth-child(3n){
				margin-right: 0;
			}
		}
		video {
			z-index: 1;
			max-width: 30%;
			max-height: 100px;
		}
	}
.BIG-cell-box {
	
	width: 94%;
	margin: 0 auto;
			background-color: #ffffff;
			border-radius: 10px;
			padding: 19px 12px 12px;
			box-sizing: border-box;
			margin-top: 12px;
			.BIG-goods-detail {
				font-size: 22px;
				font-weight: bold;
				color: #000;
			}
			.BIG-goods-price {
				margin-top: 23px;
				font-size: 20px;
				font-weight: bold;
				color: #ff0000;
				text {
					font-size: 28px;
				}
			}
			.BIG-num {
				font-size: 20px;
				color: #ff0000;
			}
			.BIG-PL-head {
				display: flex;
				// justify-content: space-between;
				align-items: center;
				.plNum {
					margin-left: 9px;
					font-size: 17px;
					color: #999;
					font-weight: normal;
				}
				text {
					font-size: 20px;
					font-weight: bold;
					color: #000;
				}
				.BIG-PL-more {
					font-size: 17px;
					font-weight: normal;
					color: #999;
					display: flex;
					align-items: center;
					.icon-BIG {
						margin-left: 8px;
					}
				}
			}
			.BIG-cell-PL-content {
				margin-top: 18px;
				padding-bottom:14px;
				border-bottom: 1px solid #e5e5e5;
				
				.BIG-cell-PL-top {
					display: flex;
					align-items: center;
					.imgBOX {
						max-width: 46px;
						max-height: 46px;
						border-radius: 50%;
						margin-right: 15px;
						image {
							max-width: 100%;
							max-height: 46px;
							border-radius: 50%;
						}
					}
					.BIG-cell-PL-main {
						flex: 1;
						.title {
							display: block;
							font-size: 18px;
							color: #000;
						}
						.time {
							font-size: 14px;
							color: #999;
						}
					}
				}
				.BIG-cell-PL-text {
					font-size: 18px;
					color: #000;
					margin-top: 13px;
				}
				
			}
		}
		
</style>
